package oo8.other;

public class People {
	private String name;
	private int age;
	private String sex;
	static {
		// 匿名静态代码块
		System.out.println("盘古开天辟地");
		System.out.println("人类出现了。。");
	}
	{
		// 匿名构造块
		System.out.println("女娲开始用黄泥捏人了。。。");
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		People other = (People) obj;
		if (age != other.age)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	public People(String name, int age) {
		super();
		System.out.println("构造开始");
		this.name = name;
		this.age = age;
	}

	public People(String name, int age, String sex) {
		this(name, age);
		this.sex = sex;
		System.out.println("构造结束");
	}

	@Override
	public String toString() {
		return "人 [name=" + name + ", age=" + age + ", sex=" + sex + "]";
	}

}
